home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
BASIC
/
LIB
/
EVENTSHELL
/
EXTENSION
/
DatePick
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1996-02-13
|
10KB
|
241 lines
Module DatePick
-----------------------------------------------------------------------
DatePick Handling Routines (version 1.03 13-Feb-96)
This library contains the 'DatePick' support routines. 'DatePick' is a
popup dialogue box which allows the choice of a date from a calendar
type display. Normally the calendar which shows the current date is
opened, but any other calendar can be displayed,
-----------------------------------------------------------------------
Public Methods Supported:
FN_shell_DatePick_Init Initialises module
PROCshell_AttachPopupDatePicker Attaches the DatePicker to a window/icon
Responses to events raised by other modules
PROCshell_DatePickerOpen Opens the DatePick DBox
Private Methods Supported:
PROCDatePicker_PreOpen
PROCDatePicker_Selection
FN_DatePicker_BumpHandler
FN_DatePicker_BumpHandler2
FN_DatePicker_DecodeDate
FN_DatePicker_Click
Message Strings required by module
monthstr
daystr
today
""*|Start FN_shell_DatePick_Init
_shell_DatePick_Init
Define Constants
'@_c_DatePick_TodayIcon% = 0 :
Default action icon
(O_c_DatePick_FirstIcon% = 11 :
First icon that holds a day number
)O_c_DatePick_LastIcon% = 53 :
Last icon that holds a day number
*N_c_DatePick_MonthIcon% = 1 :
Icon handle of month display icon
+M_c_DatePick_MonthIncIcon% = 3 :
Icon handle month increment icon
,M_c_DatePick_MonthDecIcon% = 4 :
Icon handle month decrement icon
-K_c_DatePick_YearIcon% = 2 :
Icon handle year display icon
.L_c_DatePick_YearIncIcon% = 55 :
Icon handle year increment icon
/L_c_DatePick_YearDecIcon% = 54 :
Icon handle year decrement icon
0K_c_DatePick_FirstWeekDayIcon% = 5 :
Icon handle first weekday icon
2H_c_DatePick_ESG% = 1 :
ESG of day nr icons
3J_c_DatePick_Sep$ = "." :
Date seperater string
4H_c_DatePick_TemplateName$ = "datepicker" :
Template identifier
Define variables
7>_m_DatePick_DBoxHandle% = -1 :
DBox window handle
8`_m_DatePick_NotifyFN$ = "" :
FN to call when selection is made in datepicker dbox
9T_m_DatePick_WindowHandle% = -1 :
Handle of window containing display icon
:Y_m_DatePick_DisplayIcon% = -1 :
Handle of icon to display resulting selection
;$_m_DatePick_CurrDay% = -1
<$_m_DatePick_CurrMonth% = -1
=$_m_DatePick_CurrYear% = -1
A#*|extract FN_DatePicker_PreOpen
B'*|extract FN_DatePicker_BumpHandler
C(*|extract FN_DatePicker_BumpHandler2
D&*|extract FN_DatePicker_DecodeDate
E!*|extract FN_DatePicker_Click
F-*|extract PROCshell_AttachPopupDatePicker
H!*|Stop FN_shell_DatePick_Init
L$*|Start PROCshell_DatePickerOpen
*|!PROCshell_DatePickerOpen
O8*|!Opens the datepicker dbox and calls the specified
P(*|!routine when a selection is made.
shell_DatePickerOpen( window_handle%, display_icon%, menu_icon%, notify_FN$ )
S._m_DatePick_WindowHandle% = window_handle%
T-_m_DatePick_DisplayIcon% = display_icon%
U*_m_DatePick_NotifyFN$ = notify_FN$
shell_OpenWindowDynamic( _c_DatePick_TemplateName$, "_DatePicker_PreOpen", "" )
shell_WindowMoveToPopUpPos( window_handle%, menu_icon%,
shell_GetDynamicWindowHandle )
Z#*|Stop PROCshell_DatePickerOpen
^!*|Start FN_DatePicker_PreOpen
_DatePicker_PreOpen( window_handle% )
loop%,monthstr$, daystr$
c,_m_DatePick_DBoxHandle% = window_handle%
"XHourglass_On"
Fill in weekday names..
loop% = 0
shell_IconPutData( _m_DatePick_DBoxHandle%, _c_DatePick_FirstWeekDayIcon% + loop%,
shell_CalendarWeekDayString( loop% + 1 ),
loop%
And 'Today' button..
shell_IconPutData( _m_DatePick_DBoxHandle%, _c_DatePick_TodayIcon%,
shell_MessageNoArgs( "today" ),
shell_AttachClickSelect( _m_DatePick_DBoxHandle%, -1, "_DatePicker_Click" )
shell_AttachHelpTag( _m_DatePick_DBoxHandle%, -1, "dpwin" )
shell_CalendarGetTodaysDate( _m_DatePick_CurrDay% , _m_DatePick_CurrMonth% , _m_DatePick_CurrYear% )
shell_DatePickerCreateCalendar( _m_DatePick_CurrDay%, _m_DatePick_CurrMonth% , _m_DatePick_CurrYear% )
shell_AttachBumpHandler( _m_DatePick_DBoxHandle%, _c_DatePick_MonthIcon%, _c_DatePick_MonthIncIcon%, _c_DatePick_MonthDecIcon%, -9999, 9999, 1,
, "_DatePicker_BumpHandler" , "_DatePicker_DecodeDate" )
shell_AttachBumpHandler( _m_DatePick_DBoxHandle%, _c_DatePick_YearIcon%, _c_DatePick_YearIncIcon%, _c_DatePick_YearDecIcon%, -9999, 9999, 1,
, "_DatePicker_BumpHandler2" , "" )
"Hourglass_Off"
| *|Stop FN_DatePicker_PreOpen
.*|Start PROCshell_DatePickerCreateCalendar
shell_DatePickerCreateCalendar( day%, month%, year% )
day_of_week%, month_str$, day_nr%, start_icon%, days_in_month%
selected%
"Hourglass_On"
B days_in_month% =
shell_CalendarDaysInMonth( month%, year% )
A day_of_week% =
shell_CalendarDayOfWeek( 1, month%, year% )
7 month_str$ =
shell_CalendarMonthString( month% )
shell_CloseWindow( _m_DatePick_DBoxHandle% )
shell_IconPutData( _m_DatePick_DBoxHandle%, _c_DatePick_YearIcon%,
( year% ),
shell_IconPutData( _m_DatePick_DBoxHandle%, _c_DatePick_MonthIcon%, month_str$,
: start_icon% = _c_DatePick_FirstIcon% + day_of_week%
Make first and last rows non-responsive to mouse clicks..
icon% = 1
^
shell_IconSetButtonType( _m_DatePick_DBoxHandle%, icon% + _c_DatePick_FirstIcon%, 0 )
\
shell_IconPutData( _m_DatePick_DBoxHandle%, icon% + _c_DatePick_FirstIcon%, "",
H
shell_IconPutData( _m_DatePick_DBoxHandle%, icon% + 39, "",
J
shell_IconSetButtonType( _m_DatePick_DBoxHandle%, icon% + 39, 0 )
J
shell_IconSetButtonType( _m_DatePick_DBoxHandle%, icon% + 46, 0 )
H
shell_IconPutData( _m_DatePick_DBoxHandle%, icon% + 46, "",
icon%
Deselect any selected icons in the ESG
X selected% =
shell_IconRadioSelection( _m_DatePick_DBoxHandle%, _c_DatePick_ESG% )
selected% >= 0
shell_IconSet( _m_DatePick_DBoxHandle%, selected%, 0 )
day_nr% = 1
days_in_month%
a
shell_IconPutData( _m_DatePick_DBoxHandle%, start_icon% + day_nr% - 1,
( day_nr% ),
Y
shell_IconSetButtonType( _m_DatePick_DBoxHandle%, start_icon% + day_nr% - 1, 3 )
l
day_nr% = _m_DatePick_CurrDay%
month% = _m_DatePick_CurrMonth%
year% = _m_DatePick_CurrYear%
Q
shell_IconSet( _m_DatePick_DBoxHandle%, start_icon% + day_nr% - 1, 1 )
day_nr%
shell_OpenWindow( _m_DatePick_DBoxHandle%,
"Hourglass_Off"
-*|Stop PROCshell_DatePickerCreateCalendar
%*|Start FN_DatePicker_BumpHandler
_DatePicker_BumpHandler( month%, button% )
year%
Uyear% =
shell_IconGetData( _m_DatePick_DBoxHandle%, _c_DatePick_YearIcon% ) )
month% < 1
year% -= 1
month% = 12
month% > 12
year% += 1
month% = 1
shell_DatePickerCreateCalendar( 1, month%, year% )
shell_CalendarMonthString( month% )
$*|Stop FN_DatePicker_BumpHandler
&*|Start FN_DatePicker_BumpHandler2
_DatePicker_BumpHandler2( year%, button% )
month%
pmonth% =
shell_CalendarMonthNumber(
shell_IconGetData( _m_DatePick_DBoxHandle%, _c_DatePick_MonthIcon% ) )
shell_DatePickerCreateCalendar( 1, month%, year% )
( year% )
%*|Stop FN_DatePicker_BumpHandler2
$*|Start FN_DatePicker_DecodeDate
_DatePicker_DecodeDate( month$ )
shell_CalendarMonthNumber( month$ )
#*|Stop FN_DatePicker_DecodeDate
*|Start FN_DatePicker_Click
_DatePicker_Click( window_handle%, icon_handle% )
_date$, day%, month%, year%, offset%
icon_handle% > _c_DatePick_FirstIcon%
icon_handle% < _c_DatePick_LastIcon%
i month% =
shell_CalendarMonthNumber(
shell_IconGetData( window_handle%, _c_DatePick_MonthIcon% ) )
c _date$ =
"0" +
shell_IconGetData( window_handle%, icon_handle% ), _c_DatePick_YearIcon% )
N _date$ += _c_DatePick_Sep$ +
"0" +
( month% ), 2 ) + _c_DatePick_Sep$
R _date$ +=
shell_IconGetData( window_handle%, _c_DatePick_YearIcon% ), 2 )
shell_CloseWindow( window_handle% )
DatePicker_Selection( _date$ )
icon_handle% = 0
shell_CalendarGetTodaysDate( day% , month% , year% )
; _date$ =
"0" +
( day% ), 2 ) + _c_DatePick_Sep$
; _date$ +=
"0" +
( month% ), 2 ) + _c_DatePick_Sep$
! _date$ +=
( year% ), 2 )
shell_CloseWindow( window_handle% )
DatePicker_Selection( _date$ )
*|Stop FN_DatePicker_Click
$*|Start PROCDatePicker_Selection
DatePicker_Selection( _date$ )
void%
_m_DatePick_NotifyFN$ <> ""
< void% =
( "FN" + _m_DatePick_NotifyFN$ + "(_date$)" )
_m_DatePick_DisplayIcon% >= 0
\
shell_IconPutData( _m_DatePick_WindowHandle%, _m_DatePick_DisplayIcon%, _date$,
#*|Stop PROCDatePicker_Selection
+*|Start PROCshell_AttachPopupDatePicker
shell_AttachPopupDatePicker( wh%, menuic%, dispic%, notify_fn$, preopen_FN$ )
shell_WindowLoaded( _c_DatePick_TemplateName$ )
wh% > 0
menuic% >= 0
shell_IconSetButtonType( wh%, menuic%, 3 )
shell_EvntAdd_PopUpMenu(
shell_GetWindowIdentifier( wh% ), menuic%, dispic%, -1, notify_fn$, preopen_FN$, _POPUP_TYPE_DATEPICK )
99,
shell_MessageOneArg( "SHELLMSG37", _c_DatePick_TemplateName$ )
**|Stop PROCshell_AttachPopupDatePicker